package com.yanqu.road.entity.unioncampwar;


import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 商帮阵营有积分的玩家数据
 */
@FieldTypeAnnotation(tableName = "t_c_union_camp_war_user", autoSave = true)
public class UnionCampWarUserData extends DataObject {

    @FieldTypeAnnotation(desc = "后台配置分组Id", select = true, update = true)
    private int centerGroupId;
    @FieldTypeAnnotation(desc = "分组Id", select = true, update = true)
    private int groupId;
    @FieldTypeAnnotation(desc = "周", select = true, update = true)
    private int weekId;
    @FieldTypeAnnotation(desc = "阵营Id")
    private int campId;
    @FieldTypeAnnotation(desc = "玩家id", update = true)
    private long userId;
    @FieldTypeAnnotation(desc = "服务器id")
    private long serverId;
    @FieldTypeAnnotation(desc = "积分")
    private int score;
    @FieldTypeAnnotation(desc = "打了哪些据点,据点id-伤害")
    private Map<Integer, Integer> attackDamageMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "排名")
    private int rank;
    @FieldTypeAnnotation(desc = "榜单领奖记录")
    private int getReward;

    /**
     * 不入库,同步游戏传的进攻次数
     */
    private int attackTimes = -1;
    /**
     * 最近一次战斗时间
     */
    private long lastAttackTime = 0;

    public UnionCampWarUserData(int centerGroupId, int groupId, int campId, long userId, long serverId, int weekId) {
        this.centerGroupId = centerGroupId;
        this.groupId = groupId;
        this.campId = campId;
        this.userId = userId;
        this.serverId = serverId;
        this.weekId = weekId;
        setInsertOption();
    }

    public UnionCampWarUserData() {
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public int getWeekId() {
        return weekId;
    }

    public void setWeekId(int weekId) {
        this.weekId = weekId;
    }

    public int getCenterGroupId() {
        return centerGroupId;
    }

    public void setCenterGroupId(int centerGroupId) {
        this.centerGroupId = centerGroupId;
    }

    public int getCampId() {
        return campId;
    }

    public void setCampId(int campId) {
        if (this.campId != campId) {
            this.campId = campId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public long getServerId() {
        return serverId;
    }

    public void setServerId(long serverId) {
        this.serverId = serverId;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
        setUpdateOption();
    }

    public Map<Integer, Integer> getAttackDamageMap() {
        return attackDamageMap;
    }

    public void setAttackDamageMap(Map<Integer, Integer> attackDamageMap) {
        this.attackDamageMap = attackDamageMap;
    }

    public void addAttackDamage(int holdId, int damage) {
        int oldDamage = attackDamageMap.getOrDefault(holdId, 0);
        attackDamageMap.put(holdId, oldDamage + damage);
        setUpdateOption();
    }

    public int getAttackTimes() {
        return attackTimes;
    }

    public void setAttackTimes(int attackTimes) {
        this.attackTimes = attackTimes;
    }

    public long getLastAttackTime() {
        return lastAttackTime;
    }

    public void setLastAttackTime(long lastAttackTime) {
        this.lastAttackTime = lastAttackTime;
    }

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        this.rank = rank;
        setUpdateOption();
    }

    public int getGetReward() {
        return getReward;
    }

    public void setGetReward(int getReward) {
        this.getReward = getReward;
        setUpdateOption();
    }
}
